﻿using System;
using System.Data;
using System.Collections.Generic;
using ElingOA6_Admin_DSJCJ.Model;
namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// PeerReviewVoter
    /// </summary>
    public partial class PeerReviewVoter
    {
        private readonly ElingOA6_Admin_DSJCJ.DAL.PeerReviewVoter dal = new ElingOA6_Admin_DSJCJ.DAL.PeerReviewVoter();
        public PeerReviewVoter()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(decimal FPeerReviewID, string FEntityNo, string FVoterDeptNo, string FVoterEmplNo)
        {
            return dal.Exists(FPeerReviewID, FEntityNo, FVoterDeptNo, FVoterEmplNo);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter GetModel(decimal FPeerReviewID, string FEntityNo, string FVoterDeptNo, string FVoterEmplNo)
        {

            return dal.GetModel(FPeerReviewID, FEntityNo, FVoterDeptNo, FVoterEmplNo);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter> modelList = new List<ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        #endregion  BasicMethod

        #region  ExtensionMethod


        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public DataTable GetAllListTable(string entityNo)
        {
            return dal.GetAllList(entityNo).Tables[0];
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<ElingOA6_Admin_DSJCJ.Model.PeerReviewVoter> GetListByEntityNo(string entityNo)
        {
            DataSet ds = dal.GetListByEntityNo(entityNo);
            return DataTableToListPeerReviewVoter(ds.Tables[0]);
        }
        /// <summary>
        ///  获得数据列表
        /// <summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-9</date>
        /// </summary>
        /// <param name="dt">一张DataTable</param>
        /// <returns>返回Model</returns>
        public List<Model.PeerReviewVoter> DataTableToListPeerReviewVoter(DataTable dt)
        {
            List<Model.PeerReviewVoter> modelList = new List<Model.PeerReviewVoter>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                Model.PeerReviewVoter model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Model.PeerReviewVoter();

                    if (dt.Rows[n]["FPeerReviewID"] != null && dt.Rows[n]["FPeerReviewID"].ToString() != "")
                    {
                        model.FPeerReviewID = decimal.Parse(dt.Rows[n]["FPeerReviewID"].ToString());
                    }
                    if (dt.Rows[n]["FEntityNo"] != null)
                    {
                        model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    }
                    if (dt.Rows[n]["FVoterDeptNo"] != null)
                    {
                        model.FVoterDeptNo = dt.Rows[n]["FVoterDeptNo"].ToString();
                    }
                    if (dt.Rows[n]["FVoterEmplNo"] != null)
                    {
                        model.FVoterEmplNo = dt.Rows[n]["FVoterEmplNo"].ToString();
                    }
                    if (dt.Rows[n]["FStatus"] != null)
                    {
                        model.FStatus = dt.Rows[n]["FStatus"].ToString();
                    }
                    if (dt.Rows[n]["FVoteDate"] != null && dt.Rows[n]["FVoteDate"].ToString() != "")
                    {
                        model.FVoteDate = DateTime.Parse(dt.Rows[n]["FVoteDate"].ToString());
                    }
                    if (dt.Rows[n]["FVoteIP"] != null)
                    {
                        model.FVoteIP = dt.Rows[n]["FVoteIP"].ToString();
                    }
                    if (dt.Rows[n]["deptName"] != null)
                    {
                        model.deptName = dt.Rows[n]["deptName"].ToString();
                    }
                    if (dt.Rows[n]["FEmpName"] != null)
                    {
                        model.FEmpName = dt.Rows[n]["FEmpName"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="peerReviewVotorModelList"></param>
        /// <param name="peerReviewID"></param>
        public void Add(List<Model.PeerReviewVoter> peerReviewVotorModelList, decimal peerReviewID)
        {
            dal.Add(peerReviewVotorModelList, peerReviewID);
        }



        #endregion  ExtensionMethod
    }
}

